{include file="public/head"/}
<link rel="stylesheet" href="__PUBLIC__phone/css/business.css"/>
<body>
<!--头部-->
<header id="headers">
    <div class="container">
        <div class="row">
            <div class="col-xs-12">
                <a href="javascript:;" class="leftRuted glyphicon glyphicon-menu-left pull-left" ></a>
                <p>业务续费</p>
            </div>
        </div>
    </div>
</header>
<!-- 业务续费 -->
<div class="business normalBox">
    <div class="container businwrap">
        <div class="businhead">
            <input type="text" name="iccid" id="iccid" onKeyUp="value=value.replace(/[^\d|a-zA-Z]/g,'')" maxlength="20" class="form-control" placeholder="请输入互联网卡ICCID号"/>
            <p class="text-center">
                <a href="javascript:;" id="scan">扫码</a>
                <a href="javascript:;" id="renew">续费</a>
            </p>
        </div>
        <ul class="hintbox">
            <li class="titles">
                温馨提示
            </li>
            <li>
                <span class="ls">1.</span>
                <span class="rs">支持已激活、有效期内已停卡的物联网卡周期续费</span>
            </li>
            <li>
                <span class="ls">2.</span>
                <span class="rs">续费成功，请联系您的客户经理审核完成，立即生效</span>
            </li>
            <li>
                <span class="ls">3.</span>
                <span class="rs">周期续费请在每月的21日前操作</span>
            </li>
            <li>
                <span class="ls">4.</span>
                <span class="rs">请务必输入正确、完整的ICCID号，因用户操作不当造成的损失本平台不予承担，所有解释权归本平台所有</span>
            </li>
        </ul>
    </div>
</div>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
    $(function(){
        wx.config({
            debug : false, // 调试模式
            appId : "<?php echo $scan_param['appid'] ?>", // 必填，公众号的唯一标识
            timestamp : "<?php echo $scan_param['timestamp'] ?>", // 必填，生成签名的时间戳
            nonceStr : "<?php echo $scan_param['noncestr'] ?>", // 必填，生成签名的随机串
            signature : "<?php echo $scan_param['signature'] ?>",// 必填，签名，见附录1
            jsApiList : ['checkJsApi', 'scanQRCode' ]
        });
        wx.error(function(res){
           reminder('扫码出错，请重试！')
        });
        wx.ready(function(){
            wx.checkJsApi({
                jsApiList: ['scanQRCode'], // 需要检测的JS接口列表
                success: function(res) {
                    // 认证成功返回信息
                }
            });
            $('#scan').on('click',function(){
                wx.scanQRCode({
                    needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                    scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
                    success: function (res) {
                        if(res.errMsg.indexOf("ok") != -1){  // 扫码成功
                            var result = res.resultStr.split(',')[1]; // 当needResult 为 1 时，扫码返回的结果
                            $('#iccid').val(result);
                        } else {
                            reminder('扫码出错，请重试！');
                        }
                    }
                });
            })
        });

        $('#renew').on('click',function(){
            var iccid = $('#iccid').val();
            if(!$.trim(iccid) || iccid.length < 19){   // 验证iccid号长度，联通19位
                reminder('请输入正确的ICCID号');
                return false;
            }
            $.post("{:url('/home/Renew/checkCard')}",{'iccid':iccid},function(data){
                if(data.code){
                    reminder(data.msg);
                    return false;
                }
                window.location.href = "/home/Renew/renew?iccid="+iccid;
            })
        })
    })
</script>
</body>
</html>